package com.j2009.springbootproject.config;


import com.j2009.springbootproject.interceptor.JWTInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * ClassName: WebMvcConfiger
 * Description:
 * date: 2021/3/25 15:19
 *
 * @author wuyafeng
 * @version 1.0   softeem.com
 */
@Configuration
public class WebMvcConfiger implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加拦截器
//        registry.addInterceptor(new LoginInterceptor())
//                //拦截所有请求
//                .addPathPatterns("/**")
//                // 定义排除拦截的地址 （需要放行的文件）
//                .excludePathPatterns("/",
//                        "/adminUser/toLogin",
//                        "/adminUser/login",
//                        "/admin/login.html",
//                        "/css/**","/js/**","/img/**","/layui-v2.5.7/**");
//

        //添加拦截器 JWT
        registry.addInterceptor(new JWTInterceptor())
                .addPathPatterns("/**")  //所有请求拦截验证
                .excludePathPatterns(  //判处拦截
                        "/user/login"
                      );

    }
}
